function mycheck() {
    var user = document.getElementById("username");
    var pd = document.getElementById("password");
    return myfun(user.value, pd.value);
}

function myfun(user, pd) {
    var xhr = new XMLHttpRequest();
    // var user = document.getElementById("username");
    // var pd = document.getElementById("password");
    xhr.open('POST', 'http://localhost:8080/user/login', false);
    // xhttp.setRequestHeader('Accept', 'application/json');
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200) {
            console.log(xhr.responseText);
            if (xhr.responseText == 0) {
                window.location.href = "http://localhost:8080/dashboard.html";
                localStorage.setItem("username", user);
                localStorage.setItem("password", pd);
            } else {
                alert("账号密码错误！");
            }
        }
    }
    var bodys = "username=" + user + "&password=" + pd;
    xhr.send(bodys);
}